<?php

// +----------------------------------------------------------------------
// | Apprh.Shop
// +----------------------------------------------------------------------
// | Copyright (c) 2017-2027 http://www.apprh.com All rights reserved.
// +----------------------------------------------------------------------
// | Notice: This code is not open source, it is strictly prohibited
// |         to distribute the copy, otherwise it will pursue its
// |         legal responsibility.
// +----------------------------------------------------------------------
// | Author: 雲溪荏苒 <290648237@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\controller;

use controller\BasicAdmin;
use service\DataService;
use service\ToolsService;
use think\Db;

/**
 * 留言管理
 * Feedback
 * @package app\admin\controller
 * @author 雲溪荏苒 <290648237@qq.com>
 * @date 2017/12/16
 */
class Feedback extends BasicAdmin
{

    /**
     * 指定当前数据表
     * @var string
     */
    public $table = 'Feedback';


    public function index()
    {

        $this->title = '留言管理';
        $get = $this->request->get();
        $db = Db::name($this->table)->order('sort asc, id asc');

        foreach (['mobile'] as $key) {
            if (isset($get[$key]) && $get[$key] !== '') {
                $db->where($key, 'like', "%{$get[$key]}%");
            }
        }

        return parent::_list($db);
    }

    /**
     * 添加
     */
    public function add() {
        return $this->_form($this->table, 'form');
    }

    /**
     * 编辑
     */
    public function edit() {
        return $this->add();
    }


    /**
     * 删除
     */
    public function del() {
        if (DataService::update($this->table)) {
            $this->success("删除成功！", '');
        }
        $this->error("删除失败，请稍候再试！");
    }
}
